package seueniumfordemoiselle.seleniumsimplify.pages;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.CacheLookup;
import org.openqa.selenium.support.FindBy;

/**
 * @author rogerio
 * Representa a página de cadastro de UF
 *
 */
public class UFCadastroPage extends BasePage{
	
	@FindBy(xpath="//input[contains(@id,'nome')]")
	@CacheLookup
	WebElement inputNome;
	
	@FindBy(xpath="//input[contains(@id,'sigla')]")
	@CacheLookup
	WebElement inputSigla;
	
	@FindBy(xpath="//a[contains(text(),'Inserir')]")
	@CacheLookup
	WebElement linkInserir;
	
	@FindBy(xpath="//a[contains(text(),'Voltar')]")
	@CacheLookup
	WebElement linkVoltar;
	
	@FindBy(xpath="//a[contains(text(),'Alterar')]")
	@CacheLookup
	WebElement linkAlterar;
	
	@FindBy(xpath="//a[contains(text(),'Apagar')]")
	@CacheLookup
	WebElement linkApagar;
	
	public UFCadastroPage(WebDriver driver) {
		super(driver);
	}
	
	public WebDriver getDriver() {
		return driver;
	}

	public void setDriver(WebDriver driver) {
		this.driver = driver;
	}
	
	public UFListPage clicarLinkInserir(){
		this.linkInserir.click();
		return new UFListPage(this.driver);		
	}
	
	public UFListPage clicarLinkVoltar(){
		this.linkVoltar.click();	
		return new UFListPage(this.driver);
	}
	
	public UFListPage clicarLinkAlterar(){
		this.linkAlterar.click();
		return new UFListPage(this.driver);
	}
	
	public UFListPage clicarLinkApagar(){
		this.linkApagar.click();
		return new UFListPage(this.driver);
	}
	
	/**
	 * Preenche o campo Nome 
	 */
	public UFCadastroPage digitarNome(String string){
		this.inputNome.clear();
		this.inputNome.sendKeys(string);
		return new UFCadastroPage(this.driver);
	}
	
	/**
	 * Preenche o campo Sigla 
	 */
	public UFCadastroPage digitarSigla(String string) {
		this.inputSigla.clear();
		this.inputSigla.sendKeys(string);
		return new UFCadastroPage(this.driver);
	}	
}
